﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;

namespace MCWorldLibrary
{
    public class BigEndianBinaryWriter : BinaryWriter
    {
        public BigEndianBinaryWriter(Stream stream) : base(stream)
        {
        }
        
        public override void  Write(int value)
        {
            base.Write(IPAddress.NetworkToHostOrder(value));
        }

        public override void  Write(long value)
        {
            base.Write(IPAddress.NetworkToHostOrder(value));
        }
        
        public override void  Write(short value)
        {
            base.Write(IPAddress.NetworkToHostOrder(value));
        }
        
        public override void  Write(ushort value)
        {
            base.Write(IPAddress.NetworkToHostOrder(value));
        }

        public override void Write(uint value)
        {
            base.Write(IPAddress.NetworkToHostOrder(value));
        }

        public override void Write(ulong value)
        {
            base.Write((ulong)IPAddress.NetworkToHostOrder((long)value));
        }
    }
}
